PHP code example of michaelmano / laramin

1. Go to this page and download the library: Download michaelmano/laramin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

michaelmano / laramin example snippets


protected function mapWebRoutes()
{
 Route::middleware('web')
   ->namespace($this->namespace)
   ->group(base_path('routes/web.php'));

 Route::middleware('web')
   ->namespace($this->namespace)
   ->group(base_path('routes/dashboard.php'));
}



Route::group([
    'middleware' => 'auth',
    'namespace' => 'Dashboard',
    'prefix' => 'dashboard',
    'as' => 'dashboard.'
], function () {
    Route::get('/', 'DashboardController@index')->name('index');
    Route::resource('/pages', 'PageController');
    Route::resource('/posts', 'PostController');
    Route::resource('/faqs', 'FaqController');
});

public function forbidden()
{
 abort(403);
}

Route::get('register', 'Auth\RegisterController@forbidden');

app/Http/Controllers/Auth/LoginController.php
app/Http/Controllers/Auth/RegisterController.php
app/Http/Controllers/Auth/ResetPasswordController.php

app/Http/Middleware/RedirectIfAuthenticated.php

@extends('laramin::layouts.standard')
@push('styles')
 You can push any overrides or additional styles here.
@endpush
@section('standard-content')
 Content here
@endsection
@push('scripts')
 You can push any javascript here.
@endpush

@extends('laramin::layouts.login')

@section('login-form')
 <form class="Form Box Box--padded animated zoomIn"method="POST" action="{{ route('login') }}">
  {{ csrf_field() }}
  <fieldset class="Form__fieldset">
   <label class="Form__label" for="email">Email address</label>
   <input class="Form__input Form__input--email" name="email" id="email" type="email" placeholder="[email protected]" "Button Button--text-link" href="{{ route('password.request') }}">Forgot password?</a>
  </fieldset>
 </form>
@endsection

'sidebar_links' => [
 [
  'url' => '/dashboard',
  'name' => 'Dashboard',
  'icon' => 'fa-window-maximize',
 ],
 [
  'url' => '/dashboard/pages',
  'name' => 'Pages',
  'icon' => 'fa-file-text',
 ],
 [
  'url' => '/dashboard/posts',
  'name' => 'Posts',
  'icon' => 'fa-newspaper-o',
 ],
 [
  'url' => '/dashboard/faqs',
  'name' => 'FAQ\'s',
  'icon' => 'fa-question',
 ],
],

'project_manager' => [
 'name' => 'John Smith',
 'email' => '[email protected]',
 'phone' => '555 55 555',
 'contact_finalised_message' => 'Thank you for contacting us, we will get back to you as soon as possible.',
],

<div class="Masonry__panel">
 <div class="Box Card">
  <header class="Card__header">
   <h5 class="Heading util-breakaway-bottom-2"><a href="{{ route('dashboard.posts.edit', $post) }}">{{ $post->title }}</a></h5>
   <small class="Heading__meta"><strong>Slug: </strong>{{ $post->slug }}</small>
  </header>
  <div class="Card__content">
   {{ $post->body }}
  </div>
  <footer class="Card__footer Row Row--valign-center">
   <div class="Cell Cell--12/12@xs Cell--4/12@xl">
    <a href="{{ route('dashboard.posts.edit', $post) }}" class="Button Button--round"><i class="fa fa-pencil"></i></a>
    @

<div class="Tag">
 <div class="Tag__name">Tag with info</div>
 <div class="Tag__info">v2</div>
</div>
<div class="Tag">
 <div class="Tag__name">Tag without info</div>
</div>

<div class="Tag">
 <div class="Tag__name">Tag with delete</div>
 <div class="Tag__remove"><i class="fa fa-times"></i></div>
</div>

<div class="Box Card">
    <header class="Card__header">
        <h5 class="Heading util-breakaway-bottom-2"><a href="{{ route('dashboard.posts.edit', $post) }}">{{ $post->title }}</a></h5>
        <small class="Heading__meta"><strong>Slug: </strong>{{ $post->slug }}</small>
    </header>
    <div class="Card__content">
        {{ $post->body }}
    </div>
    <footer class="Card__footer Row Row--valign-center">
        <div class="Cell Cell--12/12@xs Cell--4/12@xl">
            <a href="{{ route('dashboard.posts.edit', $post) }}" class="Button Button--round"><i class="fa fa-pencil"></i></a>
            @

<form enctype="multipart/form-data" class="Form" method="POST" action="{{ route('login') }}">
 <fieldset class="Form__fieldset">
  <label class="Form__label" for="fullName">Text</label>
  <input class="Form__input Form__input--text" name="fullName" id="fullName" type="text" or="comment">Textarea</label>
  <textarea class="Form__input Form__input--textarea"></textarea>
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="date">Date</label>
  <input class="Form__input Form__input--date" type="date">
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="checkbox">Checkbox
   <input class="Form__input Form__input--checkbox" name="checkbox" id="checkbox" type="checkbox">
  </label>
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="radio">Radio
   <input class="Form__input Form__input--radio" name="radio" id="radio" type="radio">
  </label>
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="email">Email</label>
  <input class="Form__input Form__input--email" name="email" id="email" type="email">
 </fieldset>

 <fieldset class="Form__fieldset">
  <input type="file" name="file[]" id="file" class="Form__input Form__input--file" data-multiple-caption="{count} files selected" multiple />
  <label for="file"><i class="fa fa-upload"></i> <span>Choose a file&hellip;</span></label>
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="month">Month</label>
  <input class="Form__input Form__input--month" name="month" id="month" type="month">
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="number">Number</label>
  <input class="Form__input Form__input--number" name="number" id="number" type="number">
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="password">Password</label>
  <input class="Form__input Form__input--password" name="password" id="password" type="password">
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="range">Range</label>
  <input class="Form__input Form__input--range" name="range" id="range" type="range">
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="search">Search</label>
  <input class="Form__input Form__input--search" name="search" id="search" type="search">
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="time">Time</label>
  <input class="Form__input Form__input--time" name="time" id="time" type="time">
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="url">Url</label>
  <input class="Form__input Form__input--url" name="url" id="url" type="url">
 </fieldset>

 <fieldset class="Form__fieldset">
  <label class="Form__label" for="week">Week</label>
  <input class="Form__input Form__input--week" name="week" id="week" type="week">
 </fieldset>

 <fieldset class="Form__fieldset">
  <button class="Button" type="submit">Submit</button>
 </fieldset>
</form>

<button class="Button" @click="showModal('modal')">Show Modal</button>
<laramin-modal ref="modal" @close="hideModal">
 <template slot="title">Modal</template>
 <template slot="body">
  <p>Modal Body Content</p>
 </template>
 <p slot="footer">Footer Content</p>
</laramin-modal>



namespace App\Traits;

use Image;
use Carbon\Carbon;
use Illuminate\Support\Facades\Storage;

trait MediaManager
{
    public function uploadImage($data)
    {
        $dimentions = json_decode($data['dimentions'], true);
        $width = floor($dimentions['width']);
        $height = floor($dimentions['height']);
        $x = floor($dimentions['x']);
        $y = floor($dimentions['y']);
        $size = $data['size'] ?? '1920, 800';

        $image_name = 'images/'.implode('-', [$this->id, Carbon::now()->timestamp, str_random(10)]).'.'.$data['image']->getClientOriginalExtension();

        $img = Image::make(file_get_contents($data['image']));
        $img->crop($width, $height, $x, $y);
        $img->resize($size);
        $img->stream();

        Storage::put('public/'.$image_name, $img);

        return $image_name;
    }

    public function deleteImage($location)
    {
        if (!empty($location) && Storage::exists('public/'.$location)) {
            return Storage::delete('public/'.$location);
        }
    }
}



namespace App;

use App\Traits\MediaManager;
use Illuminate\Database\Eloquent\Model;

class Page extends Model
{
    use MediaManager;
}



namespace App\Http\Controllers\Dashboard;

use App\Page;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class PageController extends Controller
{
    public function update(Page $page, Request $request)
    {
        if ($request->has(['image', 'image_dimentions'])) {
            $data = [
                'image' => $request->file('image'),
                'dimentions' => $request->get('image_dimentions')
            ];
            $page->deleteImage($page->feature_image);
            $page->feature_image = $page->uploadImage($data);
            $page->save();
        }
        $page->update($request->only('title', 'body'));

        return back()->withMessage('The page has been updated.');
    }
}

<laramin-tabs>
 <laramin-tab name="Tab 1">
  <p>Content for tab 1</p>
 </laramin-tab>
 <laramin-tab name="Tab 2">
  <p>Content for tab 2</p>
 </laramin-tab>
</laramin-tabs>

<laramin-tags-input
 name="tags[]"
 :autocomplete="['Suggestion 1',' Suggestion 2', 'Suggestion 3']"
 :tags="['tag1', 'tag2', 'tag3']">
</laramin-tags-input>`



namespace App\Http\Controllers\Dashboard;

use App\Post;
use App\Tag;
use App\Http\Controllers\Controller;

class PostController extends Controller
{
    public function update(Post $post)
    {
        $tags = collect(request('tags'))->map(function ($tag) {
            return Tag::firstOrCreate(['name' => ucfirst($tag)])->id;
        });
        $post->tags()->sync($tags);
        $post->update(request()->except('_token', '_method', 'tags'));

        return back()->withMessage('The post has been updated');
    }
}

@ 'value' => $page->title,
 'url' => route('dashboard.pages.destroy', $page),
 'delete_text' => 'Delete Page',
 'remove' => '.Masonry__panel'
])

<div class="Row js-sortable">
 @foreach($faqs as $faq)
  <div class="Cell Cell--12/12@xs js-sortable-item">
   <div class="Box Card">
    <header class="Card__header">
     <h6 class="Heading"><a href="{{ route('dashboard.faqs.edit', $faq) }}">{{ $faq->title }}</a></h6>
    </header>
    <div class="Card__content">
     {{ $faq->body }}
    </div>
    <footer class="Card__footer Row Row--valign-center">
     <div class="Cell Cell--align-left Cell--6/12@xs">
      <button class="Button Button--round js-sortable-tile"><i class="fa fa-arrows"></i></button>
      <form action="{{ route('dashboard.faqs.update', $faq) }}" method="POST">
       <input class="js-sortable-input" type="hidden" value="{{ $faq->order }}">
      </form>
     </div>
     <div class="Cell Cell--align-right Cell--6/12@xs">
      <a href="{{ route('dashboard.faqs.edit', $faq) }}" class="Button Button--round"><i class="fa fa-pencil"></i></a>
      @