Work on incomes & expanse
This commit is contained in:
32
app/Console/Commands/page.php
Normal file
32
app/Console/Commands/page.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class page extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'page:new {name}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create Inertia page folder with .vue and .scss files';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
shell_exec('mkdir '.getcwd().'\resources\js\Pages\\'.$this->argument('name'));
|
||||
shell_exec('echo. > '.getcwd().'\resources\js\Pages\\'.$this->argument('name').'\\'.strtolower($this->argument('name')).'.vue');
|
||||
shell_exec('echo. > '.getcwd().'\resources\js\Pages\\'.$this->argument('name').'\\'.strtolower($this->argument('name')).'.scss');
|
||||
}
|
||||
}
|
||||
43
app/Http/Controllers/TransactionsController.php
Normal file
43
app/Http/Controllers/TransactionsController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Income;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class TransactionsController extends Controller
|
||||
{
|
||||
public $table = 'incomes';
|
||||
|
||||
public function index(){
|
||||
|
||||
$query = $this->queryBuilder();
|
||||
$data['incomes']['columns'] = collect($query->columns)->map(function($item){
|
||||
return ucfirst(substr($item, strrpos($item, '.')+1));
|
||||
});
|
||||
$data['incomes']['data'] = $query->get();
|
||||
return Inertia::render('Transactions/index', $data);
|
||||
}
|
||||
|
||||
|
||||
private function queryBuilder(){
|
||||
$query = DB::table($this->table)
|
||||
->select([
|
||||
// 'users.account',
|
||||
// 'users.role',
|
||||
// 'users.email',
|
||||
'incomes.amount',
|
||||
'incomes.description',
|
||||
'incomes.date',
|
||||
'type_incomes.label'
|
||||
])
|
||||
->join('users', 'users.id', 'incomes.id_user')
|
||||
->join('type_incomes', 'type_incomes.id', 'incomes.id_type_income')
|
||||
;
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,9 @@ use Inertia\Inertia;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Use to login a user
|
||||
*/
|
||||
public function login(Request $request){
|
||||
$credentials = $request->validate([
|
||||
'email' => ['required', 'email'],
|
||||
@@ -19,7 +22,7 @@ class UserController extends Controller
|
||||
|
||||
return redirect()->intended('/');
|
||||
}
|
||||
return redirect()->back()->withErrors([
|
||||
return back()->withErrors([
|
||||
'message' => 'The provided credentials do not match our records.',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@ class HandleInertiaRequests extends Middleware
|
||||
'message' => fn () => $request->session()->get('message')
|
||||
],
|
||||
'appName' => config('app.name'),
|
||||
'auth.user' => fn () => $request->user()
|
||||
? $request->user()->only('id', 'name', 'email', 'role', 'account')
|
||||
: null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user